#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <math.h> 
#include <ctype.h> 
#include <time.h> 
#include <assert.h>

typedef long long LL;
LL f[100010] = { 0 }, a[100010] = { 0 };

int main()
{
	int n, m;
	int l, r;
	scanf("%d%d", &n, &m);

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		f[i] = f[i - 1] + a[i];
	}

	while (m--)
	{
		scanf("%d%d", &l, &r);
		printf("%lld\n", f[r] - f[l - 1]);
	}

	return 0;
}